package com.msb.controller;

import com.msb.pojo.Book;
import com.msb.service.BookService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.ArrayList;
import java.util.List;

/**
 * @author wuJiaWei
 * @version 1.0
 */
@Controller
public class BookController {
    @Autowired
    private BookService bookService;//注入接口类

    @RequestMapping(value = "/findAllBooks",produces = "text/html;charset=utf-8")//访问路径
//    @ResponseBody //将返回值直接返回给前端
    public String findAll(){
        List all = bookService.findAll();
        String books = "";
        for (int i = 0; i < all.size(); i++) {
            Book book = (Book)all.get(i);
            books += book.getName()+"<br/>";
        }
        System.out.println(books);
        return "index.jsp";
    }
}
